﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Excel2DbTool.Helpers
{
    class DateTimeHelper
    {
        //    2011/4/24  15:02:00
        static readonly IEnumerable<string> timeFormats = new List<string>() { "yyyy/MM/dd HH:mm:ss", "yyyy/M/dd HH:mm:ss", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd H:mm:ss","dd-MM-yyyy" };
        public static Boolean IsDateTimeType(String dateStr)
        {
            Regex regex = new Regex(@"^\d{2}-\w{2}-\d{4}");
            return regex.IsMatch(dateStr);
        }

        static bool TryFormat(string s, string format, IFormatProvider formatProvider, out DateTime time)
        {
            return DateTime.TryParseExact(s, format, formatProvider, System.Globalization.DateTimeStyles.None, out time);
        }
    }
}
